import request from '@/utils/axios'

// ====== 存款 ======
// 创建存款申请
export const createDepositApplication = (data: {
  "deposit_settings_id": number,
  "payment_method_id": number,
  "amount": number
}) => {
  return request.post({ url: `/api/v1/client/deposit.apply`, data })
}

// 获取存款记录
export const getDepositRecord = (params?: any) => {
  return request.get({ url: `/api/v1/client/deposit.apply`, params })
}

// 获取存款设置
export const getDepositSettings = () => {
  return request.get({ url: `/api/v1/client/deposit.settings` });
}

// 获取公司存款账号
export const getDepositCompanyAccountByPaymentId = (payment_method_id: string) => {
  return request.get({ url: `/api/v1/client/deposit.company.account?payment_method_id=${payment_method_id}` })
}

// ======= 取款 =======
// 创建取款申请
export const createApplicationForWithdrawal = (data : {
  "amount": number,
  "client_bankcard_id": number,
}) => {
  return request.post({ url: `/api/v1/client/withdrawal.apply` , data })
}
// 获取取款记录
export const getCashWithdrawalRecord = (params?: any) => {
  return request.get({ url: `/api/v1/client/withdrawal.record`, params })
}
// 获取取款信息
export const getCashWithdrawalInfo = () => {
  return request.get({ url: `/api/v1/client/withdrawal.info` })
}

// ======= 钱包 =======
// 资金转入转出
export const walletTransfer = (data : {
  "amount": number,
  "game_channel_id": number[],
  "ty": number, // 1：转入（游戏平台转入到客户账户），2：转出（客户账户转出到游戏平台）
  "request_id"?:number,
}) => {
  return request.post({ url: `/api/v1/client/wallet.transfer`, data })
}
// ======= 投注 ========
// 获取投注记录
export type TGetBettingRecordParams = {
  start?: string;
  end?: string;
  date?: string;
  dates?: any;
  
  client_id?: number;
  game_channel_id?: number;
  game_type_id?: number;
  game_kind?: string;
  current?: number;
  pageSize?: number;
}
export const getBettingRecord = (params: TGetBettingRecordParams) => {
  return request.get({ url: `/api/v1/client/bet`, params })
}

// 获取资金记录

export type TGetCapitalRecordParams = {
  start?: string;
  end?: string;
  date?: string;
  dates?: any; // 前端临时使用

  change_type?: number;  // 1、用户存取款。2、资金转账（平台转游戏账户）。3、游戏转账（游戏转游戏账户）。4、活动奖励。5、每日返水。6、推广佣金。7、人工扣除。8、游戏消费。9、优惠券发放失败。10、预支优惠
 
  current?: number;
  pageSize?: number;
}
export const getCapitalRecord = (params: TGetCapitalRecordParams) => {
  return request.get({ url: `/api/v1/client/capital.record`, params })
}

// ======= 银行卡&虚拟货币 ======
export const addBankCard = (data: {
  "withdrawal_password": string,
  "ty"?: number, // 1、虚拟账号，2银行卡
  "bank_id": number,
  "number": string,
  "sub_branch": string,
}) => {
  data.ty = 2;
  return request.post({ url: `/api/v1/client/bank_card`, data })
}
// 添加虚拟货币
export const addVirtualCurrency = (data: {
  "withdrawal_password": string,
  "ty"?: number, // 1、虚拟账号，2银行卡
  "address": string,
  "bank_id": number,
}) => {
  data.ty = 1;
  return request.post({ url: `/api/v1/client/bank_card`, data })
}

// 获取客户添加的银行卡列表
export const getUserBankCardList = () => {
  return request.get({ url: `/api/v1/client/bank_card`})
}

// 获取系统的银行列表
export const getSystemBankCardList = () => {
  return request.get({ url: `/api/v1/client/bank/list`})
}
// 获取系统支持的银行卡列表
export const getSystemSupportBankCardList = () => {
  return request.get({ url: `/api/v1/client/bank_card`})
}